package com.ch01;

import java.text.DecimalFormat;
import java.util.function.Function;

interface IMoneyFormat{
	String format(int i);
}
class MyMoney{
	private final int money;
	public MyMoney(int money){
		this.money = money;
	}
//	public void printMoney(IMoneyFormat moneyFormat){
//		System.out.println("我的金额为："+moneyFormat.format(this.money)+"元");
//	}
	public void printMoney(Function<Integer, String> moneyFormat){
		System.out.println("我的金额为："+moneyFormat.apply(this.money)+"元");
	}
}
public class ManaDemo {
	public static void main(String[] args) {
		MyMoney myMoney = new MyMoney(99999);
		myMoney.printMoney(i->new DecimalFormat("#.###").format(i));
	}
}
